#include <iostream>
#include <string>

// 容器
#include <vector>

using namespace std;

struct stu
{
public:
    string name;  // 名字
    string skill; // 技能
    int id;       // 学号

public:
    stu() {}

    stu(string name, string skill, int id) : name(name), skill(skill), id(id) {}
};

int main(int argc, char const *argv[])
{
    // 创建容器
    vector<stu> stu_v_1;

    // 插入操作
    // push_back
    stu_v_1.push_back(stu("唐三", "复活吧,我的爱人!!!", 1));
    stu_v_1.push_back(stu("萧炎", "佛怒火莲", 2));
    stu_v_1.push_back(stu("林动", "大荒囚天指", 3));

    // insert 先创建迭代器
    vector<stu>::iterator it = stu_v_1.begin();

    // advance(it, 2);
    it = it + 2;

    stu_v_1.insert(it, stu("牧尘", "灵阵,起!!!", 4));

    stu_v_1.insert(it, stu("陈平安", "妈来!!!", 4));
    // 遍历操作
    for (vector<stu>::iterator it = stu_v_1.begin(); it != stu_v_1.end(); it++)
    {
        stu temp = *it;
        cout << "姓名:" << temp.name << " 技能:" << temp.skill << " 学号:" << temp.id << endl;
    }

    cout << endl;
    // 删除操作
    // 尾删
    stu_v_1.pop_back();

    for (vector<stu>::iterator it = stu_v_1.begin(); it != stu_v_1.end(); it++)
    {
        stu temp = *it;
        cout << "姓名:" << temp.name << " 技能:" << temp.skill << " 学号:" << temp.id << endl;
    }
    // 删除操作
    //
    it = stu_v_1.begin();
    stu_v_1.erase(it);

    for (vector<stu>::iterator it = stu_v_1.begin(); it != stu_v_1.end(); it++)
    {
        stu temp = *it;
        cout << "姓名:" << temp.name << " 技能:" << temp.skill << " 学号:" << temp.id << endl;
    }
    return 0;
}



